﻿#pragma once

#include "precomp.h"
#include "effect.h"
#include "renders.h"
#include "sound.h"
#include "player.h"
#include "resources.h"
#include "global_state.h"

struct DialogAction{
	int atype;
	int int_param;
	CL_String text;
};

class GameDialog{
public:
	GameDialog();
	~GameDialog();

	void Init(CL_GraphicContext &gc, CL_VirtualDirectory vdir, float stime, float atime, CL_Font_Freetype* rfont, CL_Font_Freetype* jfont);
	void StartDialog(CL_String name);
	void UpdateDialog(float time, int key_fire);
	void RenderDialog(CL_GraphicContext &gc);
private:
	float dialog_time;
	unsigned int current_action;
	int dialog_state;
	int left_char;
	int right_char;
	int show_pic;
	float time_mark;

	float starting_time;
	float char_appear_time;
	double wait_time;

	float lpos;
	float rpos;
	float vpos;
	float hsize;
	float vsize;

	std::vector<DialogAction> dialog_actions;
	CL_ResourceManager dialog_res;
	CL_Sprite *dialog_frame;
	CL_Sprite *left_sprite;
	CL_Sprite *right_sprite;
	CL_Sprite *pic_sprite;
	CL_String line1;
	CL_String line2;
	CL_String line3;
	float l1rpos;
	float l2rpos;
	float l3rpos;
	float l1jpos;
	float l2jpos;
	float l3jpos;
	float llpos;
	CL_Font_Freetype *russian_font;
	CL_Font_Freetype *japanese_font;
};

extern GameDialog dialogs;
